package com.egao;

import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA;
import com.egao.common.core.Constants;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * @Description:
 * @Author: Athrun
 * @Date: 2024/12/26
 * @Version 1.0
 */
public class Main {
    public static void main(String[] args) {
        System.out.println(new BCryptPasswordEncoder().encode("123456"));
        RSA rsa = new RSA(Constants.RSA_PRIVATE_KEY, Constants.RSA_PUBLIC_KEY);
        String user = rsa.encryptBase64("z0009999", KeyType.PublicKey);
        String pwd = rsa.encryptBase64("123456", KeyType.PublicKey);
        System.out.println(user);
        System.out.println(pwd);
        rsa = new RSA(Constants.RSA_PRIVATE_KEY, Constants.RSA_PUBLIC_KEY);
        user = StrUtil.str(rsa.decrypt(user, KeyType.PrivateKey), CharsetUtil.CHARSET_UTF_8);
        pwd = StrUtil.str(rsa.decrypt(pwd, KeyType.PrivateKey), CharsetUtil.CHARSET_UTF_8);
        System.out.println(user);
        System.out.println(pwd);
    }
}
